from django.core.mail import send_mail
from chat.settings import EMAIL_FROM
import logging

logging.basicConfig(level=logging.INFO,
                    format=
                    '%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s'
                    )


def send_register_email(email, email_body):

    email_title = "Register function to send email"
    # 使用Django内置函数完成邮件发送。四个参数：主题，邮件内容，发件人邮箱地址，收件人（是一个字符串列表）
    send_status = send_mail(email_title, email_body, EMAIL_FROM, [email])
    if send_status:
        logging.info('send email success,message:{} receive_email:{}'.format(email_body, email))
    else:
        logging.info('send email failed')
